import datetime

from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from rest_framework.exceptions import ValidationError

from jiaozi.utils import check_mobile_code
from .models import *


class LoginSerializer(serializers.Serializer):
    code = serializers.CharField(help_text='code')


class MobileLoginSerializer(serializers.Serializer):
    mobile = serializers.CharField(help_text='手机号')
    code = serializers.CharField(help_text='验证码')


class GetDocSerializer(serializers.Serializer):
    key_word = serializers.CharField(help_text='key_word')


class GetCodeSerializer(serializers.Serializer):
    mobile = serializers.CharField(help_text=_('手机号'), max_length=11, min_length=11)


class BindMobileSerializer(serializers.Serializer):
    mobile = serializers.CharField(help_text=_('手机号'), max_length=11, min_length=11)
    code = serializers.CharField(help_text=_('验证码'), max_length=6)


class UserAddressSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserAddress
        exclude = ['datetime_created', 'datetime_updated']


class FeedBackSerializer(serializers.ModelSerializer):

    class Meta:
        model = FeedBack
        exclude = ['datetime_created', 'datetime_updated', 'is_checked']


class WxUserSerializer(serializers.ModelSerializer):

    class Meta:
        model = WxUser
        fields = ['pk', 'nick_name', 'mobile', 'date_of_birth', 'gender']


class GetWxTokenSerializer(serializers.Serializer):
    signature = serializers.CharField(required=False)
    timestamp = serializers.CharField(required=False)
    nonce = serializers.CharField(required=False)
